package cn.edu.zut.service.impl;


import cn.edu.zut.dao.IBookIndexDao;
import cn.edu.zut.domin.BookIndex;
import cn.edu.zut.service.IBookIndexService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class BookIndexServiceImpl implements IBookIndexService {
    @Autowired
    IBookIndexDao bookIndexDao;

    //查找索引
    @Override
    public List<BookIndex> findAll(int page, int size) throws Exception {
        PageHelper.startPage(page,size);
        return bookIndexDao.findAll();
    }

    //查找索引，by Id
    @Override
    public List<BookIndex> findBookIndexByTypeId(String id) throws Exception {
        return bookIndexDao.findBookByTypeId(id);
    }

    //保存索引
    @Override
    public void saveBookIndex(BookIndex bookIndex) throws Exception {
        bookIndexDao.saveBookIndex(bookIndex);
    }

    //删除索引
    @Override
    public void deleteBookIndex(String typeId) throws Exception {
        bookIndexDao.deleteBookIndex(typeId);
    }

    //更新索引
    @Override
    public void updateBookIndex(BookIndex bookIndex) throws Exception {
        bookIndexDao.updateBookIndex(bookIndex);
    }

}
